package com.JobFind.DAO.impl;

import java.util.List;

import javax.annotation.Resource;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Component;

import com.JobFind.DAO.ICompanyDAO;
import com.JobFind.model.TbCompany;

@Component
public class CompanyDAO implements ICompanyDAO {
	private SessionFactory sessionFactory;

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	@Resource
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	@SuppressWarnings("unchecked")
	public List<TbCompany> loginCheck(String companyLoginName) throws Exception {
		List<TbCompany> result = null;
		Session session = sessionFactory.getCurrentSession();
		String hql = "from TbCompany where companyLoginName = ?";
		Query query = session.createQuery(hql);
		query.setString(0,companyLoginName);
		result = query.list();
		return result;
	}
}
